using SG3L_RAG.Application.DTOs;
using System.Security.Claims;

namespace SG3L_RAG.Application.Interfaces;

/// <summary>
/// JWT认证服务接口
/// </summary>
public interface IJwtService
{
    /// <summary>
    /// 生成JWT Token
    /// </summary>
    /// <param name="user">用户信息</param>
    /// <returns>Token信息</returns>
    Task<LoginResponseDto> GenerateTokenAsync(UserInfoDto user);

    /// <summary>
    /// 验证Token
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <returns>验证结果</returns>
    Task<TokenValidationResponseDto> ValidateTokenAsync(string token);

    /// <summary>
    /// 从Token中提取用户信息
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <returns>用户信息</returns>
    Task<UserInfoDto?> GetUserFromTokenAsync(string token);

    /// <summary>
    /// 从Claims中提取用户信息
    /// </summary>
    /// <param name="claims">Claims集合</param>
    /// <returns>用户信息</returns>
    UserInfoDto? GetUserFromClaims(IEnumerable<Claim> claims);

    /// <summary>
    /// 刷新Token
    /// </summary>
    /// <param name="token">当前Token</param>
    /// <returns>新的Token信息</returns>
    Task<LoginResponseDto?> RefreshTokenAsync(string token);
}

/// <summary>
/// 认证服务接口
/// </summary>
public interface IAuthService
{
    /// <summary>
    /// 用户登录
    /// </summary>
    /// <param name="loginDto">登录信息</param>
    /// <returns>登录结果</returns>
    Task<LoginResponseDto?> LoginAsync(LoginDto loginDto);

    /// <summary>
    /// 用户注册
    /// </summary>
    /// <param name="registerDto">注册信息</param>
    /// <returns>注册结果</returns>
    Task<LoginResponseDto> RegisterAsync(RegisterDto registerDto);

    /// <summary>
    /// 验证用户凭据
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="password">密码</param>
    /// <returns>验证结果</returns>
    Task<UserInfoDto?> ValidateUserAsync(string username, string password);
}
